package com.meichis.yndms.vm;

import android.text.TextUtils;

import androidx.lifecycle.MutableLiveData;

import com.meichis.yndms.model.ClientInfo;
import com.meichis.yndms.model.ShopInfo;
import com.meichis.yndms.model.VstInfo;
import com.meichis.yndms.repository.manager.ClientDetailManager;

/**
 * @author xmy
 * @title
 * @remake
 * @create 2021-05-08 15:23
 */
public class ClientDetailVM extends MyViewModel {

    private MutableLiveData<ShopInfo> shopInfo;
    private MutableLiveData<VstInfo> vstInfo;
    private ClientInfo clientInfo;
    private String DMSID;

    public String getDMSID() {
        if (TextUtils.isEmpty(DMSID)){
            DMSID = getClientInfo().getDMSID();
        }
        return DMSID;
    }

    public void setDMSID(String DMSID) {
        this.DMSID = DMSID;
    }

    public ClientInfo getClientInfo() {
        return clientInfo;
    }

    public void setClientInfo(ClientInfo clientInfo) {
        this.clientInfo = clientInfo;
    }


    public MutableLiveData<VstInfo> getVstInfo() {
        if (vstInfo == null){
            vstInfo = new MutableLiveData<>();
        }
        return vstInfo;
    }

    public MutableLiveData<ShopInfo> getShopInfo() {
        if (shopInfo == null) {
            shopInfo = new MutableLiveData<>();
        }
        return shopInfo;
    }


    public void GetShopInfo() {
        ClientDetailManager.getInstance().GetShopInfo(getShowDialog(), getUserInfo().getValue().getOrgId(),
                getUserInfo().getValue().getId(), getDMSID(), getShopInfo());
    }

    public void GetTerminalLastVisit() {
        ClientDetailManager.getInstance().GetTerminalLastVisit(getShowDialog(), getUserInfo().getValue().getOrgId(),
                getDMSID(), getVstInfo());
    }
}
